package cn.edu.xmu.talk.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.xmu.talk.bean.MessageBean;

public class SendMessageServlet extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 8786955865048433269L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		String content = req.getParameter("content");
		String friendId = req.getParameter("to");
		String myId = req.getSession().getAttribute("userId").toString();
		MessageBean.send(content,friendId,myId);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req,resp);
	}

	
}
